package com.hilon.aixinmis1.base.flow;

import com.hilon.foundation.base.BaseController;
import com.hilon.foundation.util.ResultBean;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/FlowControl")
public class FlowControlController
        extends BaseController<FlowControl, FlowControl> {
    private final FlowControlService flowControlService;

    public FlowControlController(FlowControlService service) {
        super.setService(service);
        this.flowControlService = service;
    }

    @PostMapping("/getFlowControlModels")
    public ResultBean<List<FlowControlModel>> getFlowControlModels(@RequestBody FlowControl flowControl) throws Exception {
        System.out.println(flowControl);
        System.out.println(flowControl.getCategoryType());
        System.out.println(flowControl.getCategoryTypeDetail());

        return flowControlService.getFlowControlModels(flowControl.getEntityName(),
                flowControl.getCategoryType(),
                flowControl.getCategoryTypeDetail());
    }
    @PostMapping("/getFlowControlsByEntityNameAndId")
    public ResultBean<List<FlowControl>> getFlowControlsByEntityNameAndId(@RequestBody FlowControl flowControl) throws Exception {
        return flowControlService.getFlowControlsByEntityNameAndId(flowControl.getEntityName(),
                flowControl.getIdReceipt());
    }
    @PostMapping("/saveAll")
    public ResultBean<String> saveAll(@RequestBody List<FlowControl> flowControls) throws Exception {
        return flowControlService.saveAll(flowControls);
    }
    @PostMapping("/saveAsModel")
    public ResultBean<String> saveAsModel(@RequestBody List<FlowControlModel> flowControlModels) throws Exception {
        return flowControlService.saveAsModel(flowControlModels);
    }

}
